/* eslint-disable import/prefer-default-export */
import React from 'react';

import { Form, Input, DatePicker } from 'antd';
import moment from 'moment';
import { FormContainer, SelectForm, RadioForm, CheckboxForm } from '@/components/UserForm';
import { getTypeList } from '@/services/components/userform';
import { findCountry } from './utils';
// import styles from '../../RecruitMange.less';

const { RangePicker } = DatePicker;
/** 新加坡招聘信息 */
const XZPXX = ({ form, disabled = true, formData }) => {
    const { getFieldDecorator } = form;
    const {
        companyId,
        companyName = '',
        applyDate = '',
        recruitPost = '',
        departmentName = '',
        projectGroup = '',
        // totalNums = '',
        // workNums = '',
        requireNums = '',
        entryDate = null,
        entryDateEnd = null,
        // necessary = '',
        reason1 = '',
        reason2 = '',
        recruitReport = '',
        workNature = '',
        otherReason = '',
        postRank = '',
        workNatureOther = ''
    } = formData;
    const { recruitReportRemark = 'GroupPost' } = findCountry(companyId);
    const flagReason2 = form.getFieldValue('reason2') === 'no_buget';
    return (
        <div className="form-Wrap">
            <FormContainer>
                <Form.Item label="需求公司">
                    {getFieldDecorator('companyName', {
                        initialValue: companyName,
                        rules: [
                            {
                                required: true
                            }
                        ]
                    })(<Input disabled={disabled} />)}
                </Form.Item>
                <Form.Item label="申请日期">
                    {getFieldDecorator('applyDate', {
                        initialValue: moment(applyDate),
                        rules: [
                            {
                                // required: true,
                                // message: '请选择入库日期'
                            }
                        ]
                    })(<DatePicker style={{ width: '100%' }} disabled={disabled} />)}
                </Form.Item>
                <Form.Item label="需求职位">
                    {getFieldDecorator('recruitPost', {
                        initialValue: recruitPost,
                        rules: [
                            {
                                required: true
                            }
                        ]
                    })(<Input disabled={disabled} />)}
                </Form.Item>
                <Form.Item label="职级">
                    {getFieldDecorator('postRank', {
                        initialValue: postRank
                    })(<Input disabled />)}
                </Form.Item>
                <Form.Item label="需求部门">
                    {getFieldDecorator('departmentName', {
                        initialValue: departmentName,
                        rules: [
                            {
                                required: true
                            }
                        ]
                    })(<Input disabled={disabled} />)}
                </Form.Item>
                <Form.Item label="项目组">
                    {getFieldDecorator('projectGroup', {
                        initialValue: projectGroup,
                        rules: [
                            {
                                // required: true
                            }
                        ]
                    })(<Input disabled={disabled} />)}
                </Form.Item>
                <Form.Item label="汇报对象">
                    {getFieldDecorator('recruitReport', {
                        initialValue: recruitReport,
                        rules: [
                            {
                                required: true
                            }
                        ]
                    })(
                        <SelectForm
                            params={{ dictCode: recruitReportRemark }}
                            requireParam={['dictCode']}
                            getData={params =>
                                getTypeList(params).then(res => {
                                    if (res && res.code === 10000 && res.data) {
                                        return res.data || [];
                                    }
                                    return [];
                                })
                            }
                            fieldsName={{
                                selectValue: 'dictValue',
                                selectTitle: 'dictName'
                            }}
                            // onChange={this.companyChange}
                            selectProps={{
                                placeholder: '',
                                disabled
                            }}
                        />
                    )}
                </Form.Item>
                <Form.Item label="需求人数">
                    {getFieldDecorator('requireNums', {
                        initialValue: requireNums,
                        rules: [
                            {
                                required: true
                            }
                        ]
                    })(<Input disabled={disabled} />)}
                </Form.Item>
                <Form.Item label="期望到岗时间">
                    {getFieldDecorator('expectTime', {
                        initialValue: entryDate ? [moment(entryDate), moment(entryDateEnd)] : null,
                        rules: [
                            {
                                required: true
                            }
                        ]
                    })(<RangePicker disabled={disabled} style={{ width: '100%' }} />)}
                </Form.Item>
            </FormContainer>
            <Form.Item label="工作性质" vvspan={24} labelCol={{ md: 4 }} wrapperCol={{ md: 20 }}>
                <span
                    style={{
                        display: 'inline-block'
                    }}
                >
                    {getFieldDecorator('workNature', {
                        initialValue: workNature,
                        rules: []
                    })(
                        <RadioForm
                            params={{ dictCode: 'jobType' }}
                            requireParam={['dictCode']}
                            getData={params =>
                                getTypeList(params).then(res => {
                                    if (res && res.code === 10000 && res.data) {
                                        return res.data || [];
                                    }
                                    return [];
                                })
                            }
                            fieldsName={{
                                radioValue: 'dictValue',
                                radioTitle: 'dictName'
                            }}
                            // onChange={this.companyChange}
                            radioProps={{
                                placeholder: '',
                                disabled
                            }}
                        />
                    )}
                </span>
                <span
                    style={{
                        display: 'inline-block',
                        width: '24%',
                        marginLeft: '2%'
                    }}
                >
                    {form.getFieldValue('workNature') === 'other' &&
                        getFieldDecorator('workNatureOther', { initialValue: workNatureOther })(
                            <Input disabled={disabled} />
                        )}
                </span>
            </Form.Item>
            <Form.Item
                label="增补原因"
                labelCol={{ md: 4 }}
                wrapperCol={{
                    md: flagReason2 ? 20 : 8
                }}
            >
                <span
                    style={{
                        display: 'inline-block',
                        width: flagReason2 ? '32%' : '49%'
                    }}
                >
                    {getFieldDecorator('reason1', {
                        initialValue: reason1,
                        rules: [
                            {
                                // required: true
                            }
                        ]
                    })(
                        <SelectForm
                            params={{ dictCode: 'SingaporeSupplyReasonLevel' }}
                            requireParam={['dictCode']}
                            getData={params =>
                                getTypeList(params).then(res => {
                                    if (res && res.code === 10000 && res.data) {
                                        return res.data || [];
                                    }
                                    return [];
                                })
                            }
                            fieldsName={{
                                selectValue: 'dictValue',
                                selectTitle: 'dictName'
                            }}
                            // onChange={this.companyChange}
                            selectProps={{
                                placeholder: '',
                                disabled
                            }}
                        />
                    )}
                </span>
                <span
                    style={{
                        display: 'inline-block',
                        width: flagReason2 ? '32%' : '49%',
                        marginLeft: '2%'
                    }}
                >
                    {form.getFieldValue('reason1') === 'quitNeed' &&
                        getFieldDecorator('otherReason', {
                            initialValue: otherReason,
                            rules: [
                                {
                                    required: true
                                }
                            ]
                        })(<Input disabled={disabled} />)}
                    {form.getFieldValue('reason1') !== 'quitNeed' &&
                        getFieldDecorator('reason2', {
                            initialValue: reason2,
                            rules: [
                                {
                                    required: true,
                                    placeholder: '请选择'
                                }
                            ]
                        })(
                            <SelectForm
                                params={{ dictCode: 'newNeedType' }}
                                requireParam={['dictCode']}
                                getData={params =>
                                    getTypeList(params).then(res => {
                                        if (res && res.code === 10000 && res.data) {
                                            return res.data || [];
                                        }
                                        return [];
                                    })
                                }
                                fieldsName={{
                                    selectValue: 'dictValue',
                                    selectTitle: 'dictName'
                                }}
                                // onChange={this.companyChange}
                                selectProps={{
                                    placeholder: '请选择',
                                    disabled
                                }}
                            />
                        )}
                </span>
                <span
                    style={{
                        display: 'inline-block',
                        width: flagReason2 ? '32%' : '0%',
                        marginLeft: '2%'
                    }}
                >
                    {form.getFieldValue('reason2') === 'no_buget' &&
                        getFieldDecorator('otherReason', {
                            initialValue: otherReason,
                            rules: [
                                {
                                    required: true
                                }
                            ]
                        })(<Input disabled={disabled} />)}
                </span>
            </Form.Item>
        </div>
    );
};

/** 新加坡候选人要求 */
const XHXRYQ = ({ form, disabled = true, formData }) => {
    const { getFieldDecorator } = form;
    const {
        requireDegree = '',
        requireSex = '',
        timeEmployed = '',
        workContent = '',
        otherContent = '',
        languageAbility = '',
        languageAbilityOther = ''
    } = formData;
    let flagReason2 = false;
    if (form.getFieldValue('languageAbility') && form.getFieldValue('languageAbility').indexOf('other') !== -1) {
        flagReason2 = true;
    }
    return (
        <div className="form-Wrap">
            <FormContainer>
                <Form.Item label="最低学历">
                    {getFieldDecorator('requireDegree', {
                        initialValue: requireDegree
                    })(
                        <SelectForm
                            params={{ dictCode: 'agreeType' }}
                            requireParam={['dictCode']}
                            getData={params =>
                                getTypeList(params).then(res => {
                                    if (res && res.code === 10000 && res.data) {
                                        return res.data || [];
                                    }
                                    return [];
                                })
                            }
                            fieldsName={{
                                selectValue: 'dictValue',
                                selectTitle: 'dictName'
                            }}
                            // onChange={this.companyChange}
                            selectProps={{
                                placeholder: '请选择',
                                disabled
                            }}
                        />
                    )}
                </Form.Item>
                <Form.Item label="性别">
                    {getFieldDecorator('requireSex', {
                        initialValue: requireSex,
                        rules: [
                            {
                                // required: true
                            }
                        ]
                    })(
                        <RadioForm
                            params={{ dictCode: 'candidateSexType' }}
                            requireParam={['dictCode']}
                            getData={params =>
                                getTypeList(params).then(res => {
                                    if (res && res.code === 10000 && res.data) {
                                        return res.data || [];
                                    }
                                    return [];
                                })
                            }
                            fieldsName={{
                                radioValue: 'dictValue',
                                radioTitle: 'dictName'
                            }}
                            // onChange={this.companyChange}
                            radioProps={{
                                placeholder: '',
                                disabled
                            }}
                        />
                    )}
                </Form.Item>
                <Form.Item label="工作年限">
                    {getFieldDecorator('timeEmployed', {
                        initialValue: timeEmployed
                    })(
                        <SelectForm
                            params={{ dictCode: 'timeEmployedType' }}
                            requireParam={['dictCode']}
                            getData={params =>
                                getTypeList(params).then(res => {
                                    if (res && res.code === 10000 && res.data) {
                                        return res.data || [];
                                    }
                                    return [];
                                })
                            }
                            fieldsName={{
                                selectValue: 'dictValue',
                                selectTitle: 'dictName'
                            }}
                            // onChange={this.companyChange}
                            selectProps={{
                                placeholder: '请选择',
                                disabled
                            }}
                        />
                    )}
                </Form.Item>
            </FormContainer>
            <Form.Item
                label="语言能力"
                labelCol={{ md: 4 }}
                wrapperCol={{
                    md: flagReason2 ? 20 : 8
                }}
            >
                <span
                    style={{
                        display: 'inline-block',
                        width: flagReason2 ? '48%' : '100%'
                    }}
                >
                    {getFieldDecorator('languageAbility', {
                        initialValue: languageAbility,
                        rules: []
                    })(
                        <CheckboxForm
                            params={{ dictCode: 'languageAbility' }}
                            requireParam={['dictCode']}
                            getData={params =>
                                getTypeList(params).then(res => {
                                    if (res && res.code === 10000 && res.data) {
                                        return res.data || [];
                                    }
                                    return [];
                                })
                            }
                            fieldsName={{
                                checkboxValue: 'dictValue',
                                checkboxTitle: 'dictName'
                            }}
                            // onChange={this.companyChange}
                            checkboxProps={{
                                placeholder: '',
                                disabled
                            }}
                        />
                    )}
                </span>
                <span
                    style={{
                        display: 'inline-block',
                        width: flagReason2 ? '48%' : '0%',
                        marginLeft: flagReason2 && '2%'
                    }}
                >
                    {flagReason2 &&
                        getFieldDecorator('languageAbilityOther', {
                            initialValue: languageAbilityOther,
                            rules: [
                                {
                                    //   required: true
                                }
                            ]
                        })(<Input disabled={disabled} />)}
                </span>
            </Form.Item>
            <FormContainer>
                <Form.Item label="职位工作内容" vvspan={24} labelCol={{ md: 4 }} wrapperCol={{ md: 20 }}>
                    {getFieldDecorator('workContent', {
                        initialValue: workContent
                    })(
                        <Input.TextArea
                            disabled={disabled}
                            rows={4}
                            style={{ 'word-break': ' break-all' }}
                            placeholder="请输入至少两个字符"
                        />
                    )}
                </Form.Item>
                <Form.Item label="其他要求" vvspan={24} labelCol={{ md: 4 }} wrapperCol={{ md: 20 }}>
                    {getFieldDecorator('otherContent', {
                        initialValue: otherContent
                    })(
                        <Input.TextArea
                            rows={4}
                            disabled={disabled}
                            style={{ 'word-break': ' break-all' }}
                            placeholder="请输入至少两个字符"
                        />
                    )}
                </Form.Item>
            </FormContainer>
        </div>
    );
};

export { XZPXX, XHXRYQ };
